1 <?php
2  session_start();
3  
if(isset($_SESSION['user']))
4  {
5
6  }
7  
else{
8   echo
"<script>location.href='login.html'</script>";
9  }
10 ?>
11 <!doctype html>
12 <html>
13 <head>
14   <title>
15   Salesdetails
16   </title>
17 <style>
18   
19   body {
20   margin:
0;
21   font-family: Arial, Helvetica, sans-serif;
22   background: #
484848;
23 }
24 .topnav {
25   overflow: hidden;
26   background-color: rgba(
249, 105, 14, 1);
27   height: 70px;
28   border: 3px solid #e69500;
29 }
30
31 .topnav a {
32   
float: left;
33   color: #f2f2f2;
34   text-align: center;
35   padding: 14px 16px;
36   text-decoration: none;
37   font-size: 35px;
38   font-weight: bold;
39 }
40
41 .topnav-right {
42   
float: right;
43 }
44
45 fieldset { max-width: 450px;
46   background: #FAFAFA;
47     padding: 30px;
48     margin: 50px auto;
49     box-shadow: 1px 1px 25px rgba(
0, 0, 0, 0.35);
50     border-radius: 10px;
51     border: 6px solid rgba(
249, 105, 14, 1);
52
53
54 }
55
56 legend {
57   padding:
0.2em 0.5em;
58   border:2px solid rgba(
249, 105, 14, 1);
59   color:green;
60   font-size:
90%;
61   text-align:center;
62   }
63 </style>
64   </head>
65 <body>
66 <div
class="topnav">
67             <a
class="active" href="home.html"><img src="ic_add_pet.png"></a>
68             <a href=
"sales.php">Sales details</a>
69             <div
class="topnav-right">
70               <a href=
"logout.php">logout</a>
71             </div>
72           </div>
73 <form>
74     <button type=
"submit" formaction="soldproducts.php" style="margin:15px;height: 30px;width: 100px;
75     border-radius:15px;
76 border: 3px solid #e69500;background-color: rgba(
249, 105, 14, 1);color:#f2f2f2;font-size:15px;cursor:pointer;">Back</button>
77 </form>
78 <form method=
"post" action="soldpdadd.php" >
79 <fieldset>
80   <input type=
"text" name="id" placeholder="Enter sales details id" style="width:100%;height:30px;
81     border: 2px solid rgba(
249, 105, 14, 1); border-radius:5px; background:transparent;" required>
82   <br><br>
83   <input type=
"text" name="pp" placeholder="Enter product id" style="width:100%;height:30px;
84     border: 2px solid rgba(
249, 105, 14, 1); border-radius:5px; background:transparent;" required>
85   <br><br>
86    <input type=
"number" name="quantity" placeholder="Enter no. of quantity " style="width:100%;height:30px;
87     border: 2px solid rgba(
249, 105, 14, 1); border-radius:5px; background:transparent;" min="1" required>
88   <br><br>
89   <input type=
"submit" name="submit" value="ADD" style="width:100%;height:30px;
90     border: 2px solid rgba(
249, 105, 14, 1); border-radius:5px; cursor:pointer;background-color: rgba(249, 105, 14, 1)">&ensp;
91   </fieldset>
92 </form>
93 </body>
94 </html>
95 <?php

96 if
(isset($_POST["submit"]))
97 {
98  
// define variables and set to empty values
99 $servername =
"localhost";
100 $username =
"root";
101 $password =
"";
102 $dbname =
"Petshop_management";
103
104 // Create connection

105 $conn =
new mysqli($servername, $username, $password, $dbname);
106 // Check connection

107 if
($conn->connect_error) {
108     die(
"Connection failed: " . $conn->connect_error);
109 }

110 //echo
" CONNECTION ESTABLISHED \r\n";
111 //echo
" INSERTION IN PROCESS";
112 $id = $_POST[
"id"];
113   $pp_id = $_POST[
"pp"];
114  $quantity=$_POST[
"quantity"];
115
116
117
118
119 $sql =
"INSERT INTO sold_products( sd_id,pp_id,quantity)
120 VALUES ('$id','$pp_id','$quantity')"
;
121 if
($conn->query($sql) == TRUE) {
122   echo
'<div>
123   <h1 style=
"color:#f2f2f2;font-size:20px; font-family: "Roboto", sans-serif;margin:auto;">New record of sales_id='
124   .$id.
'and pp_id='.$pp_id. ' inserted successfully</h1>
125      </div>
';
126     $conn->query(
"call calculations_for_product('$pp_id','$id','$quantity')");
127 }
else {
128     echo
"Error: " . $sql . "<br>" . $conn->error;
129 }
130
131 $conn->close();
132 }
133
134 ?>


Gõ tìm kiếm nhanh...